package cn.earas.ip.frame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import cn.earas.ip.*;

public class OutFrame extends JFrame
{
    public static boolean outFlag;
    private static final long serialVersionUID = 1L;
    private JButton jButton1;
    private JComboBox<String> jComboBox1;
    private JFileChooser jFileChooser1;
    private JLabel jLabel1;
    private JLabel jLabel2;
    private JTextField jTextField1;
    
    public OutFrame() {
        this.initComponents();
    }
    
    private void initComponents() {
        this.jFileChooser1 = new JFileChooser();
        this.jLabel1 = new JLabel();
        this.jComboBox1 = new JComboBox<String>();
        this.jLabel2 = new JLabel();
        this.jTextField1 = new JTextField();
        this.jButton1 = new JButton();
        this.setBounds(Toolkit.getDefaultToolkit().getScreenSize().width / 2 - 162, Toolkit.getDefaultToolkit().getScreenSize().height / 2 - 43, 324, 86);
        this.setTitle("\u5bfc\u51fa");
        this.setResizable(false);
        final Toolkit tk = Toolkit.getDefaultToolkit();
        final Image imgae = tk.createImage(this.getClass().getResource("/images/logo.png"));
        this.setIconImage(imgae);
        this.jLabel1.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", 0, 12));
        this.jLabel1.setText("\u9009\u62e9\u5206\u9694\u7b26\uff1a");
        this.jComboBox1.setEditable(true);
        this.jComboBox1.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", 0, 12));
        this.jComboBox1.setModel(new DefaultComboBoxModel<String>(new String[] { ",", ";", ":", "'", "\"", "@", "#", "$", "&", "*", "换行" }));
        this.jLabel2.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", 0, 12));
        this.jLabel2.setText("\u5bfc\u51fa\u4f4d\u7f6e\uff1a");
        this.jTextField1.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", 0, 12));
        this.jTextField1.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(final MouseEvent evt) {
                OutFrame.this.jTextField1MouseClicked(evt);
            }
        });
        this.jTextField1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent evt) {
                OutFrame.this.jTextField1ActionPerformed(evt);
            }
        });
        this.jButton1.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", 0, 12));
        this.jButton1.setText("\u5f00\u59cb\u5bfc\u51fa");
        this.jButton1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent evt) {
                OutFrame.this.jButton1ActionPerformed(evt);
            }
        });
        final GroupLayout layout = new GroupLayout(this.getContentPane());
        this.getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.jLabel2).addComponent(this.jLabel1)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(this.jComboBox1, -2, -1, -2).addGap(18, 18, 18).addComponent(this.jButton1).addGap(0, 0, 32767)).addComponent(this.jTextField1)).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel2).addComponent(this.jTextField1, -2, -1, -2)).addGap(18, 18, 18).addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jComboBox1, -2, -1, -2).addComponent(this.jLabel1).addComponent(this.jButton1)).addContainerGap(-1, 32767)));
        this.pack();
    }
    
    private void jTextField1ActionPerformed(final ActionEvent evt) {
    }
    
    private void jButton1ActionPerformed(final ActionEvent evt) {
    	outFlag = false;
        MainFrame.of.dispose();
        final LoadingFrame lf = new LoadingFrame("\u6b63\u5728\u5bfc\u5165\uff0c\u8bf7\u7a0d\u540e\u3002\u3002\u3002");
        lf.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(final WindowEvent e) {
                OutFrame.outFlag = true;
                super.windowClosing(e);
            }
        });
        lf.setVisible(true);
        final String path = this.jTextField1.getText();
        String split = this.jComboBox1.getSelectedItem().toString();
        if(split.equals("换行")) split = "\r\n";
        new Thread(new DataUtil(6, path, split, lf)).start();
    }
    
    private void jTextField1MouseClicked(final MouseEvent evt) {
        (this.jFileChooser1 = new JFileChooser()).setFileSelectionMode(1);
        final int returnVal = this.jFileChooser1.showOpenDialog(this.jFileChooser1);
        if (returnVal == 0) {
            this.jTextField1.setText(this.jFileChooser1.getSelectedFile().getAbsolutePath());
        }
    }
    
    static {
        OutFrame.outFlag = false;
    }
}
